import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:xiaomi/app/modules/tools/storageService.dart';

class SearchPageController extends GetxController {
  //TODO: Implement SearchPageController
  RxList<String> hist = <String>[].obs;

  TextEditingController textEditingController = TextEditingController();
  final count = 0.obs;
  @override
  void onInit() {
    super.onInit();

    StorageClient.getHist().then((result) {
      if (result is String) {
        print("结果是字符串：$result");
      } else if (result is List) {
        hist.value = result as List<String>;
        update();
        print("结果是列表：$result ${result.runtimeType}");
      } else {
        print("结果的类型：${result.runtimeType}");
      }
    }).catchError((error) {
      print("发生错误：$error");
    });
  }

  deleteAll() {
    StorageClient.deleteAll();
    update();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  void increment() => count.value++;
}
